package com.isoft.c2team3service2.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isoft.c2team3service2.entity.User;
import com.isoft.c2team3service2.entity.UserDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Update("update tb_login set password=#{password} ,salt=#{salt} where email=#{email}")
    int updatePassword(String email, String password, String salt);

    @Insert("insert into tb_login (email, password,salt) values (#{email}, #{password},#{salt})")
    int addUser(String email, String password, String salt);
    // 在UserMapper中
    @Select("SELECT id, email, password, salt, nick_name, user_name, photourl FROM user WHERE id = #{id}")
    UserDTO selectUserDTOById(Integer id);

    @Select("SELECT role_id FROM user_role  where user_id=#{userId}")
    Integer selectUserRoleId(Integer userId);

}
